/**
 * 
 */
package com.common.bean;

import org.json.JSONException;
import org.json.JSONObject;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import com.common.StarAppConst.IM_MESSAGE_KEY;
import com.common.allCommon.JSONObjecthelper;

/**
 * 朋友升级IM消息推送信息存储类 <br>
 * Created 2014-11-6 下午1:51:34
 * 
 * @version
 * @author ChuXY
 * 
 * @see
 */

public class FriendDevelopEventData extends AppMsgData implements Parcelable,
		ICommonImDataStruct, ICommonIMFriendInfo {

	/** 个人空间url 客户端通过朋友昵称id连接到个人空间地址 */
	private long mPersonlUrl = 0;

	/** 附件文件扩展名，因extra_id中可能存在语音文件，导致客户端消息展示失败，故提供sort进行判断 */
	private String mSort = "";

	/** 显示个人空间朋友升级消息内容 */
	private String mSummary = "";

	/** 消息类型 */
	private String mType = "";
	/**
	 * 消息内容
	 */
	private String mMessage = "";

	/** 时间戳 */
	private long mTime = 0;

	/** 昵称 */
	private String mUniqueName = "";

	/** 用户id */
	private long mUid = 0;

	/** 用户头像id */
	private long mFileId = 0;

	/** 朋友昵称ID */
	private long mFriendUid = 0;

	/** 朋友昵称 */
	private String mFriendUniqueName = "";

	/** 朋友头像id */
	private long mFriendFileId = 0;

	/**
	 * @return the mFriendUid
	 */
	public long getFriendUid() {
		return mFriendUid;
	}

	/**
	 * @param mFriendTid
	 *            the mFriendTid to set
	 */
	public void setFriendUid(long friendUid) {
		this.mFriendUid = friendUid;
	}

	/**
	 * @return the mPersonlUrl
	 */
	public long getPersonlUrl() {
		return mPersonlUrl;
	}

	/**
	 * @param mPersonlUrl
	 *            the mPersonlUrl to set
	 */
	public void setPersonlUrl(long personlUrl) {
		this.mPersonlUrl = personlUrl;
	}

	/**
	 * @return the mSort
	 */
	public String getSort() {
		return mSort;
	}

	/**
	 * @param mSort
	 *            the mSort to set
	 */
	public void setSort(String sort) {
		this.mSort = sort;
	}

	/**
	 * @return the mSummary
	 */
	public String getSummary() {
		return mSummary;
	}

	/**
	 * @param mSummary
	 *            the mSummary to set
	 */
	public void setmSummary(String summary) {
		this.mSummary = summary;
	}

	/**
	 * Creates a new instance of FriendDevelopEventData <br>
	 * Created 2014-11-3 下午5:30:39
	 */
	public FriendDevelopEventData() {
		super();
	}

	/**
	 * 获取业务类型 <br>
	 * Created 2014-11-4 下午1:45:38
	 * 
	 * @return 业务类型
	 * @author ChuXY
	 */
	public String getType() {
		return mType;
	}

	/**
	 * 设置消息类型
	 * 
	 * <br>
	 * Created 2014-11-4 下午1:45:58
	 * 
	 * @param mType
	 * @author ChuXY
	 */
	public void setType(String mType) {
		this.mType = mType;
	}

	/**
	 * 获取消息内容
	 * 
	 * <br>
	 * Created 2014-11-4 下午1:46:17
	 * 
	 * @return 消息内容
	 * @author ChuXY
	 */
	public String getMessage() {
		return mMessage;
	}

	/**
	 * 设置消息内容
	 * 
	 * <br>
	 * Created 2014-11-4 下午1:46:48
	 * 
	 * @param mMessage
	 *            消息内容
	 * @author ChuXY
	 */
	public void setMessage(String mMessage) {
		this.mMessage = mMessage;
	}

	/**
	 * 获取时间戳
	 * 
	 * <br>
	 * Created 2014-11-4 下午1:47:08
	 * 
	 * @return 时间戳
	 * @author ChuXY
	 */
	public long getTime() {
		return mTime;
	}

	/**
	 * 设置时间戳
	 * 
	 * <br>
	 * Created 2014-11-4 下午1:47:19
	 * 
	 * @param mTime
	 *            时间戳
	 * @author ChuXY
	 */
	public void setTime(long mTime) {
		this.mTime = mTime;
	}

	/**
	 * 获取昵称
	 * 
	 * <br>
	 * Created 2014-11-4 下午1:47:30
	 * 
	 * @return 昵称
	 * @author ChuXY
	 */
	public String getUniqueName() {
		return mUniqueName;
	}

	/**
	 * 设置昵称
	 * 
	 * <br>
	 * Created 2014-11-4 下午1:47:39
	 * 
	 * @param mUniqueName
	 *            昵称
	 * @author ChuXY
	 */
	public void setUniqueName(String mUniqueName) {
		this.mUniqueName = mUniqueName;
	}

	/**
	 * 获取uid
	 * 
	 * <br>
	 * Created 2014-11-4 下午1:47:49
	 * 
	 * @return 用户id
	 * @author ChuXY
	 */
	public long getUid() {
		return mUid;
	}

	/**
	 * 设置uid
	 * 
	 * <br>
	 * Created 2014-11-4 下午1:48:05
	 * 
	 * @param mUid
	 * @author ChuXY
	 */
	public void setUid(long mUid) {
		this.mUid = mUid;
	}

	public static final Parcelable.Creator<FriendDevelopEventData> CREATOR = new Creator<FriendDevelopEventData>() {

		@Override
		public FriendDevelopEventData[] newArray(int size) {
			return new FriendDevelopEventData[size];
		}

		@Override
		public FriendDevelopEventData createFromParcel(Parcel in) {
			return new FriendDevelopEventData(in);
		}
	};

	/**
	 * Creates a new instance of UserUpdateData. <br>
	 * Created 2014-11-3 下午3:17:45
	 * 
	 * @param in
	 */
	public FriendDevelopEventData(Parcel in) {
		mMessage = in.readString();
		mTime = in.readLong();
		mType = in.readString();
		mUniqueName = in.readString();
		mUid = in.readLong();
		mFriendUid = in.readLong();
		mPersonlUrl = in.readLong();
		mSort = in.readString();
		mSummary = in.readString();
		mFileId=in.readLong();
		mFriendFileId=in.readLong();
		mFriendUniqueName=in.readString();
	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeString(mMessage);
		dest.writeLong(mTime);
		dest.writeString(mType);
		dest.writeString(mUniqueName);
		dest.writeLong(mUid);
		dest.writeLong(mFriendUid);
		dest.writeLong(mPersonlUrl);
		dest.writeString(mSort);
		dest.writeString(mSummary);
		dest.writeLong(mFileId);
		dest.writeLong(mFriendFileId);
		dest.writeString(mFriendUniqueName);
	}

	@Override
	public void parseJson(String strJson) {
		if (TextUtils.isEmpty(strJson)) {
			return;
		}

		JSONObject jsonData = null;
		try {
			jsonData = new JSONObject(strJson);
		} catch (JSONException e) {
			return;
		}
		mType = JSONObjecthelper.getString(jsonData, IM_MESSAGE_KEY.TAG_TYPE);
		mMessage = JSONObjecthelper.getString(jsonData, IM_MESSAGE_KEY.TAG_MSG);
		mTime = JSONObjecthelper.getLong(jsonData, IM_MESSAGE_KEY.TAG_TIME);
		mUid = JSONObjecthelper.getLong(jsonData, IM_MESSAGE_KEY.TAG_USERID);
		mUniqueName = JSONObjecthelper.getString(jsonData,
				IM_MESSAGE_KEY.TAG_UNIQUENAME);
		mFriendUid = JSONObjecthelper.getLong(jsonData,
				IM_MESSAGE_KEY.TAG_FRIENDTID);
		mPersonlUrl = JSONObjecthelper.getLong(jsonData,
				IM_MESSAGE_KEY.TAG_PERSONURL);
		mSort = JSONObjecthelper.getString(jsonData, IM_MESSAGE_KEY.TAG_SORT);
		mSummary = JSONObjecthelper.getString(jsonData,
				IM_MESSAGE_KEY.TAG_SUMMARY);
		mFileId=JSONObjecthelper.getLong(jsonData,
				IM_MESSAGE_KEY.TAG_CHECK_CODE);
		mFriendFileId=JSONObjecthelper.getLong(jsonData,
				IM_MESSAGE_KEY.TAG_FRIEND_CHECK_CODE);
		mFriendUniqueName = JSONObjecthelper.getString(jsonData,
				IM_MESSAGE_KEY.TAG_FRIEND_UNIQUENAME);
	}

	@Override
	public String transDataToJSON() {
		JSONObject json = new JSONObject();
		try {
			json.put(IM_MESSAGE_KEY.TAG_TYPE, mType);
			json.put(IM_MESSAGE_KEY.TAG_MSG, mMessage);
			json.put(IM_MESSAGE_KEY.TAG_TIME, mTime);
			json.put(IM_MESSAGE_KEY.TAG_UNIQUENAME, mUniqueName);
			json.put(IM_MESSAGE_KEY.TAG_USERID, mUid);
			json.put(IM_MESSAGE_KEY.TAG_PERSONURL, mFriendUid);
			json.put(IM_MESSAGE_KEY.TAG_SORT, mSort);
			json.put(IM_MESSAGE_KEY.TAG_SUMMARY, mSummary);
			json.put(IM_MESSAGE_KEY.TAG_CHECK_CODE, mFileId);
			json.put(IM_MESSAGE_KEY.TAG_FRIEND_CHECK_CODE, mFriendFileId);
			json.put(IM_MESSAGE_KEY.TAG_FRIEND_UNIQUENAME, mFriendUniqueName);
			
		} catch (JSONException e) {
			e.printStackTrace();
			return null;
		}
		return json.toString();
	}

	@Override
	public void setDataFromJSON(String jsonString) {
		parseJson(jsonString);
	}
	
	@Override
	public long getFileId() {
		return mFileId;
	}


	@Override
	public void setFileId(long fileId) {
		mFileId=fileId;
	}

	@Override
	public void setFriendUniqueName(String friendUniqueName) {
		mFriendUniqueName=friendUniqueName;
	}


	@Override
	public String getFriendUniqueName() {
		return mFriendUniqueName;
	}


	@Override
	public void setFriendFileId(long fid) {
		mFriendFileId=fid;
	}

	@Override
	public long getFriendFileId() {
		return mFriendFileId;
	}

	/**
	 * 
	 * <br>Created 2014-11-14 下午10:19:11
	 * @return
	 * @author       ChuXY	
	*/
	
	@Override
	public long getLongExtraData() {
		// TODO Auto-generated method stub
		return 0;
	}

	/**
	 * 
	 * <br>Created 2014-11-30 下午4:08:23
	 * @return
	 * @author       ChuXY	
	*/
	
	@Override
	public String getStringExtraData() {
		// TODO Auto-generated method stub
		return null;
	}

}
